package com.yeyaomai.dksns.flowis.service.impl;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Service;
import com.yeyaomai.dksns.flowis.dao.ReferDomainDao;
import com.yeyaomai.dksns.flowis.domain.ReferDomain;
import com.yeyaomai.dksns.flowis.page.PageImplResult;
import com.yeyaomai.dksns.flowis.page.PageRequestOrder;
import com.yeyaomai.dksns.flowis.page.SplitConstant;
import com.yeyaomai.dksns.flowis.service.ReferDomainService;

/**
 * 来路域名服务类
 * @author xiaqin
 *@date 2012-06-13
 */
@Service
public class ReferDomainServiceImpl implements ReferDomainService {

	@Resource
	private ReferDomainDao referDomainDao;

	@Override
	public void addReferDomain(ReferDomain referDomain) {
		referDomainDao.addReferDomain(referDomain);

	}

	@Override
	public ReferDomain getReferDomainById(long id) {
		return referDomainDao.getReferDomainById(id);
	}

	@Override
	public List<ReferDomain> getReferDomainByDay(Map<String,Object> map) {
		return referDomainDao.getReferDomainByDay(map);

	}

	@Override
	public Page<ReferDomain> getDataPage(Map<String, Object> map,Integer currentpage) {
		long domainCount = referDomainDao.getReferDomainCount(map.get("fromReferDay").toString(),map.get("toReferDay").toString());
		PageRequestOrder request = new PageRequestOrder(currentpage, SplitConstant.PAGE_SIZE);
		List<ReferDomain> domainList = new ArrayList<ReferDomain>();
		map.put("startNumber", request.start());
		map.put("endNumber", request.end());
		domainList = referDomainDao.getReferDomainByDay(map);
		Page<ReferDomain> result = new PageImplResult<ReferDomain>(domainList, request, domainCount);
		return result;
	}

}
